module.exports = function ($scope, $resource, toaster) {

	$scope.status = false;
	$scope.order_code = '';

	$scope.getCount = function(code){
		$resource('/api/as/tc/ticket2/getTicketDisabled', {}, {}).save({'order_code':code}, function (res) {
            if (res.errcode === 0) {
				$scope.orderInfo.num0 = res.data.num0;
				$scope.orderInfo.num1 = res.data.num1;
            } else {
                toaster.error({ title: '', body: '查询订单信息失败' });
            }
        });
	}
	
	$scope.check = function () {
		$resource('/api/as/tc/ticketorder/ordersaleinfobycode', {}, {}).save({'code':$scope.order_code}, function (res) {
            if (res.errcode === 0) {
				$scope.orderInfo = res.data;
				$scope.status = true;
				$scope.getCount($scope.order_code)
            } else {
                toaster.error({ title: '', body: '查询订单信息失败' });
            }
        });
	};

	//查询景区下属票机
	$scope.gogogo = function () {
		if(!$scope.status){
			return;
		}
		$resource('/api/ac/tc/ticketService/setTicketDisabled', {}, {}).save({'order_code':$scope.order_code}, function (res) {
            if (res.errcode === 0) {
				toaster.success({ title: '', body: '成功消票 ' + res.data.num + ' 张' });
				$scope.getCount($scope.order_code)
            } else {
                toaster.error({ title: '', body: res.errmsg });
            }
        });
	};

};